<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
</head>
<body>
<a href="index.html">返回</a>
<div class="app">
    <h2>自定义指令</h2>
    <div>
            count:{{count}}
        <input type="text" v-mybind:value="count">
        <button @click="count++">加1</button>
    </div>
</div>
<script>
    Vue.config.productionTip=false  //关闭生产状态提示
    const x=new Vue({
        // el:".app",
        data:function (){  //data的第二种写法
            return{
                count:1
            }
        },
        directives:{
            mybind: {
                // element.value =binding.value
                bind(element, binding) {
                    console.log("bind", element, binding)
                    element.value = binding.value
                },
                inserted(element, binding) {
                    console.log("inserted", element, binding)
                  //  element.value = binding.value
                },
                update(element, binding) {
                    console.log("update", element, binding)
                    element.value = binding.value
                 }
            }
        }
    })
        x.$mount(".app")//挂载方式
</script>
</body>
</html>